package de.fzi.kasma.learner.function.kernel;

import de.fzi.kasma.learner.data.Data;
import de.fzi.kasma.learner.data.Dataset;
import de.fzi.kasma.learner.data.TrainingData;
import de.fzi.kasma.learner.path.PathGraph;
import edu.unika.aifb.graphindex.storage.StorageException;

public class HypothesisKernel extends Kernel {
	
	
	private PathGraph[] clauses;

	public HypothesisKernel(PathGraph[] clauses)
	{
		this.setClauses(clauses);
	}
	
	@Override
	public double getValue(Data d) {
		// TODO Auto-generated method stub
		TrainingData data= (TrainingData) d;	
		return 0;
	}
	
	public double getSimilarity(Data x, Data y, Dataset dataset) throws StorageException{
		
		double similarity = 0;
		for(PathGraph pg : getClauses()){
			
			ClauseKernel ck = new ClauseKernel(pg);
			similarity += ck.getSimilarity(x, y, dataset);
		}
		
		return similarity;
		
	}

	public int getComplexity() {

		int complexity =0;
		for(PathGraph pg : getClauses()){
			complexity += pg.edgeCount();
		} 
		return complexity;
	}


	public Matrix calculateMatrix(Dataset dataset) {

        
		return new Matrix(dataset, this);
		
	}
	public KernelMatrix calculateKernelMatrix(Dataset dataset) {

        
		return new KernelMatrix(dataset, this);
		
	}

	public KernelMatrix calculateMatrix(Dataset dataset, Data x) {
		// TODO Auto-generated method stub
		return null;
	}

	public void setClauses(PathGraph[] clauses) {
		this.clauses = clauses;
	}

	public PathGraph[] getClauses() {
		return clauses;
	}

}
